<template>
	<div class="list list5 house">
		<yd-infinitescroll :callback="loadList" ref="infinitescrollDemo">
			<yd-list theme="5" slot="list">
				<yd-list-item class="my-yd-list-img" v-for="item, key in data" :key="key" @click.native="detailsrouter(item.id)">
					<div class="swiper-img" slot="img">
						<!--<img slot="img" v-if="item.houseImgUrl.indexOf('?')==-1" :src="item.houseImgUrl+'?imageslim'">-->
						<img slot="img" :src="item.houseImgUrl">
						<div class="sh-price">￥<span>{{item.prices}}</span>/晚</div>
						<!--收藏-->
						<div class="like-icon" v-if="isCollect" @click.stop="selectSort($event,item.id)">
							<yd-icon name="like" color="#FF685D"></yd-icon>
						</div>
					</div>
					<yd-list-other slot="other">
						<div class="house5-introduce">
							<p class="swiper-text">{{item.title}}</p>
							<div class="swiper-item">
								<span v-if="item.houseRent==1">民宿套房 </span>
								<span v-if="item.roomRent==1">人民单间 </span>
								<span v-if="item.bedRental==1">青年床位 </span>
								<span>{{item.room}}室{{item.hall}}厅{{item.toilet}}卫</span>
								<span>宜居{{item.personNumber}}人</span>
								<span>{{item.centiare}}m²</span>
							</div>
						</div>
						<div class="house5-portrait">
							<!--<img v-if="item.imgUrl.indexOf('?')==-1" :src="item.imgUrl+'?imageslim'" />-->
							<img :src="item.imgUrl" />
						</div>
					</yd-list-other>

				</yd-list-item>
			</yd-list>
			<!-- 数据全部加载完毕显示 -->
			<span slot="doneTip">暂无更多房源信息</span>
			<!-- 加载中提示，不指定，将显示默认加载中图标 -->
			<img slot="loadingTip" src="http://static.ydcss.com/uploads/ydui/loading/loading10.svg" />

		</yd-infinitescroll>
	</div>
</template>

<script>
	import { mapGetters, mapActions } from 'vuex'
	import api from '../fetch/api'
	export default {
		name: 'ShortView',
		data() {
			return {
				page: 1,
				userId: "",
				token: ""
			}
		},
		props: ["data"],
		computed: {
			...mapGetters([
				'isCollect',
			])
		},
		mounted() {
			var that = this;
			if(sessionStorage.getItem("userinfo") != null) {
				let getHiss = JSON.parse(sessionStorage.getItem("userinfo"));
				that.userId = getHiss.id;
				that.token = getHiss.token;
			}
		},
		methods: {

			//			详情路由跳转
			detailsrouter(houseId) {
				var that = this;

				that.$router.push({
					path: '/shortDetails',
					query: {
						houseId: houseId
					}
				})
			},
			loadList() {
				var that = this;
				/* 单次请求数据完毕 */
				that.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');
				that.page++;
				that.$emit('collectlist', that.page);

			},
			selectSort(e, houseId) {
				let ajaxSign = {
					"source": "web",
					"token": this.token,
					"userId": this.userId.toString(),
					"houseId": houseId.toString(),
					"type": '2',
					"houseType": '2',
				}
				let ajaxData = api.getAES(ajaxSign);
				api.GetCollectSta(ajaxData)
					.then(res => {
						if(res.sta == 200) {

							this.$parent.collectlistdata = [];
							this.$parent.collectlist(1)
						}
						this.$dialog.toast({
							mes: res.msg,
							timeout: 1000
						});
						if(res.sta == 203) {
							this.$router.push({
								path: "/login"
							})
						}
					})

			},
		}
	}
</script>

<style>
	@import url("../assets/css/listfive.css");
	.house .yd-list-loading>div {
		display: block !important;
	}
</style>